import { defineStore } from "pinia";
import createUserStore from './user'

function delay() {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve()
        }, 1000)
    })
}

export default defineStore({
    id: 'storeName',
    state() {
        return {
            name: 'xiaohong',
            count: 1
        }
    },
    getters: {
        double() {
            const userStore = createUserStore()
            return this.count * 2 + userStore.age
        }
    },
    actions: {
        async changeCount(val) {
            await delay()
            this.count = val
        }
    }
})
